package com.wonderful.mall.product.web;

import com.wonderful.mall.product.entity.CategoryEntity;
import com.wonderful.mall.product.service.CategoryService;
import com.wonderful.mall.product.vo.Catalog2Vo;
import org.redisson.api.RLock;
import org.redisson.api.RReadWriteLock;
import org.redisson.api.RedissonClient;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.UUID;

@Controller
public class IndexController {
    @Resource
    private CategoryService categoryService;

    @GetMapping({"/","/index.html"})
    public String index(Model model){
        //查出所有1级分类
        List<CategoryEntity> list = categoryService.getLevel1Category();
        model.addAttribute("category",list);
        return "index";
    }

    @ResponseBody
    @GetMapping("/index/json/catalog.json")
    public Map<String, List<Catalog2Vo>> getCatalogJson(){
       return categoryService.getCatalogJson();
    }
}
